{extend name="lib/common_list" /}
{block name="title"}{/block}
{block name="css"}
{load href="/static/sys/css/common.css" /}
{load href="/static/plugins/select2/css/select2.css" /}
{load href="/static/plugins/bootstrap-datetimepicker/css/bootstrap-datetimepicker.css" /}

{load href="/static/sys/css/skin_0.css" /}
<style>
    .upfile i{padding-right:3px !important;}
    .file{ position:absolute;right:0;top:0;width:100px;height:100px;opacity:0; ilter:alpha(opacity=0);cursor:pointer;margin-bottom: 0px;margin-right: 0px; }
</style>
{/block}
{block name="javascript"}
{load  href="/static/plugins/select2/js/select2.js" /}
{load  href="/static/plugins/bootstrap-datetimepicker/js/bootstrap-datetimepicker.js" /}
{load  href="/static/plugins/bootstrap-datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js" /}

<script>
    $(document).ready(function () {
        $("#ok").bind("click", edit);
        $("#cancel").bind("click", function () {
            parent.layer.close(parent.layer_edit_index);
        });

        /**
         * 保存内容
         */
        function edit() {
            var load_index = layer.load(0, { shade: false });
            $.ajax({
                type: 'POST',
                url: "{:url('album_skin_category/edit')}",
                data: $("#fmNew").serialize(),
                dataType: 'json',
                success: function (data) {
                    if (data.code == 1) {
                        //window.parent.location.replace(location.href);
                        layer.alert(data.msg, function () {
                            layer.close(load_index);
                            parent.refreshtb();
                            parent.layer.close(parent.layer_edit_index);
                        });
                    } else {
                        layer.alert(data.msg);
                    }
                }
            })
        }

        // 时间插件
        $('.form_datetime').datetimepicker({
            weekStart: 0, //一周从哪一天开始
            todayBtn:  1, //
            autoclose: 1,
            todayHighlight: 1,
            startView: 2,
            forceParse: 0,
            //showMeridian: 1,
            language:'zh-CN',
            format: 'yyyy-mm-dd',
            minView:'month',
        });
    });


    function isNumber(value) {         //验证是否为数字
        var patrn = /^(-)?\d+(\.\d+)?$/;
        if (patrn.exec(value) == null || value == "") {
            return false
        } else {
            return true
        }
    }

    function trim(str) { // 去除空格
        return str.replace(/(^\s*)|(\s*$)/g, "");
    }

</script>
{/block}

{block name="content"}
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-content">
                    <form method="post" id="fmNew" class="form-horizontal" enctype="multipart/form-data">

                        <div class="form-group">
                            <label class="col-sm-2 control-label">类别名称：</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" name="title" value="{$Rs.title}" placeholder="请输入名称">
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label">描叙：</label>
                            <div class="col-sm-8">
                                <textarea name="desc" cols="3">{$Rs.desc}</textarea>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label">状态：</label>
                            <div class="col-sm-8">
                                <select class="form-control" name="status" id="status">
                                    {volist name="status_list" id="v"}
                                    <option value="{$key}" {if($key == $Rs.status)} selected {/if}>{$v}</option>
                                    {/volist}
                                </select>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label">排序：</label>
                            <div class="col-sm-8">
                                <input type="number" class="form-control" name="sort" value="{$Rs.sort}" placeholder="越小越靠前">
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>

                        <div id = 'hidden_input'>
                            <input name="id" value="{$Rs.id}" type="hidden"/>
                        </div>

                        <div class="form-group">
                            <div class="col-sm-12 col-sm-offset-5">
                                <button class="btn btn-primary" id="ok" type="button">提交</button>
                                <button class="btn btn-white" id="cancel" type="button">取消</button>
                            </div>
                        </div>

                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
{/block}